metadata:
  name: onnx-projectp-yolov5
  namespace: cvat
  annotations:
    name: YOLO v5 Project P
    type: detector
    framework: onnx
    spec: |
      [
        { "id": 0, "name": "background" },
        { "id": 1, "name": "pelican" }
      ]

spec:
  description: Ultralytics YOLO v5 via ONNX (no NMS) Project P
  runtime: 'python:3.8'
  handler: main:handler
  eventTimeout: 30s
  build:
    image: cvat.onnx.projectp.yolov5
    baseImage: ubuntu:22.04

    directives:
      preCopy:
        - kind: USER
          value: root
        - kind: RUN
          value: apt update && apt install --no-install-recommends -y git wget python3-pip
        - kind: RUN
          value: pip install -r https://raw.githubusercontent.com/Shining-Future/project-p-inference/master/requirements.txt pyyaml && pip install -e git+https://github.com/Shining-Future/project-p-inference.git#egg=projectp && true
        - kind: WORKDIR
          value: /opt/nuclio
        - kind: RUN
          value: wget https://github.com/Shining-Future/project-p-assets/raw/master/models/yolov5s-no-nms-2022-07-07-last.onnx
        - kind: RUN
          value: ln -s /usr/bin/python3 /usr/bin/python

  triggers:
    myHttpTrigger:
      maxWorkers: 2
      kind: 'http'
      workerAvailabilityTimeoutMilliseconds: 10000
      attributes:
        maxRequestBodySize: 33554432 # 32MB

  platform:
    attributes:
      restartPolicy:
        name: always
        maximumRetryCount: 3
      mountMode: volume
